package com.example.imitation_webchat_demo.application;

import java.lang.Thread.UncaughtExceptionHandler;

import com.example.imitation_webchat_demo.util.ApplicationUtils;

import android.app.Application;

// 当app启动时运行的类MyApplication
public class MyApplication extends Application {
	private UncaughtExceptionHandler handler;

	@Override
	public void onCreate() {
		super.onCreate();
		
		 handler = new UncaughtExceptionHandler(){
			@Override
			public void uncaughtException(Thread thread, Throwable ex) {
				ApplicationUtils.getInstance().exit();
			}
		 };
		 Thread.setDefaultUncaughtExceptionHandler(handler); // 程序崩溃时触发线程
	}
}